﻿Public Class clsInhSkladChemiczny
    Inherits clsSkladChemiczny

#Region "Attributes"
    Dim mvarSklad As clsInhSklad
#End Region

#Region "Properties"

    Public Property Sklad() As clsInhSklad
        Get
            Return mvarSklad
        End Get
        Set(ByVal value As clsInhSklad)
            mvarSklad = value
        End Set
    End Property

#End Region

#Region "Methods"

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal ID As Integer, ByVal lvarDbHolder As clsDataBase)
        MyBase.New(ID.ToString(), lvarDbHolder, VAR_ERROR_HANDLER)
        mvarSklad = New clsInhSklad(MyBase.SkladId, lvarDbHolder)
    End Sub

    Public Overloads Sub Save(ByVal lvarDbHolder As clsDataBase)
        MyBase.Save(lvarDbHolder, VAR_ERROR_HANDLER)
    End Sub

    Public Overloads Sub Delete(ByVal lvarDbHolder As clsDataBase)
        MyBase.Delete(lvarDbHolder, VAR_ERROR_HANDLER)
    End Sub

    Public Function PobierzSkladMaterialu(ByVal lvarDbHolder As clsDataBase, ByVal Zapytanie As Integer) As DataTable

        Dim lvarReader As OdbcDataReader = Nothing
        Dim lvarReturn As DataTable = Nothing

        If lvarDbHolder.IsOpen Then
            Dim lvarSqlRunner As New clsSqlRunner(lvarDbHolder, "queries_application_oem", "cls_sklad_chemiczny", 1, VAR_ERROR_HANDLER)

            With lvarSqlRunner
                .AddParameter("p_id", Zapytanie.ToString())
                lvarReader = .ExecuteQuery
            End With

            If lvarReader.HasRows Then
                lvarReturn = New DataTable
                lvarReturn.Load(lvarReader)
            End If

        End If

        Return lvarReturn

    End Function

#End Region

End Class
